<?php
if (!$con = mysql_connect('localhost', 'root', 'rootpass')) {
    echo 'Could not connect to mysql';
    exit;
}
if (!mysql_select_db('honeyviz', $con)) {
    echo 'Could not select database';
    exit;
}
$query = 	"SELECT category.event_name, period, quantity, loc.longitude, loc.latitude
		FROM cached_events
		LEFT JOIN locations.locations AS loc ON cached_events.location_id = loc.location_id
		LEFT JOIN category ON cached_events.category_id = category.category_id;";
$result = mysql_query($query);
echo "<?xml version = '1.0' ?><data>";
while ($row = mysql_fetch_assoc($result)) {
	echo "<result>";
	echo "<category>" . $row['event_name'] . "</category>";
	echo "<time>" . $row['period'] . "</time>";
	echo "<count>" . $row['quantity'] . "</count>";
	echo "<longitude>" . $row[longitude] . "</longitude>";
	echo "<latitude>" . $row[latitude] . "</latitude>";
	echo "</result>";
}
echo "</data>";
mysql_close($con);
?>
